/*jslint sloppy: true */
/*global require */
var probe = require('../../global');
var angular = require('angular');

probe.service('cmd', function ($rootScope) {
	var maxLength = 30,
		cmd = $rootScope.console = {
			log: []
		};

	cmd.push = function (message, level) {
		var lL = this.log.length;

		this.log.push({
			message: message,
			level: level,
			time: new Date()
		});

		// clip log.
		if (lL > maxLength) {
			this.log.shift();
		}

		return;
	};

	cmd.clear = function () {
		this.log.length = 0;

		return;
	};

	return cmd;
});
